﻿using System;
using UnityEngine;
using UnityEngine.EventSystems;

public class TouchScenes
{

    public Action<RaycastHit> HitSthCallback;

    GameObject _root;

    public TouchScenes()
    {
        _root = UIManager.instance.Add("UI/FightUI/TouchScene", UILayer.Touch);

        var touchRotate = _root.GetComponent<TouchRotate>();
        touchRotate.PointUpCallback = onTouchScene;

    }

    private void onTouchScene(PointerEventData eventData)
    {
        //eventData.pointerClick
        Ray ray = Camera.main.ScreenPointToRay(eventData.position);

        RaycastHit ret;

        Debug.Log("触摸屏幕1");
        if (Physics.Raycast(ray, out ret))
        {
            Debug.Log("触摸屏幕2");
            Debug.Log(ret.transform.gameObject);
            if (HitSthCallback != null)
            {
                HitSthCallback(ret);
            }
            
        }
        

    }
}
